<template>
    <div>
        <h2>医生信息显示</h2>
        <a href="/ysadd">去医生添加</a>
        <tr></tr>

        <a href="/bfxs">去病房显示</a>
        <tr></tr>

        <a href="/ksxs">去科室显示</a>
        <tr></tr>

           <table class="table">
            <thead>
                <tr>
                    <td>姓名</td>
                    <td>头像</td>
                    <td>科室</td>
              
                    <td>创建日期</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                 <tr v-for="m in data">
                    <td>{{ m.xm }}</td>
                    <td><img :src="'https://localhost:7209/'+m.img" style="width: 60px;height: 60px;"></td>
                    <td>{{ m.ksmc }}</td>
                    <td>{{ moment(m.kscjrq).format("YYYY-MM-DD") }}</td>
                </tr>
            </tbody>
           </table>
                    <input type="button" value="首页" @click="page(1)">
                    <input type="button" value="上一页" @click="page(2)">
                    <input type="button" value="下一页" @click="page(3)">
                    <input type="button" value="尾页" @click="page(4)">
           

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,onMounted } from 'vue';


const page=(a:any)=>{
    if(a==1){
        que.value.index=1;
        ysxs();
    }
       if(a==2){
        if(que.value.index>1){
 que.value.index-=1;
        ysxs();
        }
       
    }
       if(a==3){
        if(que.value.index<quer.value.page){
              que.value.index+=1;
        ysxs();
        }
      
    }
       if(a==4){
        que.value.index=quer.value.page;
        ysxs();
    }
}

const data=ref([{
    "ysid": 1,
      "xm": "",
      "img": "",
      "ksid": 1,
      "yscjrq": "2025-05-19T02:14:55.238",
      "ksmc": "毛细血管科室",
      "ksms": "主要是毛细血管出血",
      "kscjrq": "2025-05-25T00:00:00"
}])
const que=ref({
   index:1,
   size:3,
})

const quer=ref({
   count:0,
   page:0,
})

onMounted(()=>{
      ysxs();
})
const ysxs=()=>{
    axios.get("https://localhost:7209/api/Doteroxxb/ysxs",{params:que.value}).then(res=>{
        data.value=res.data.page

        quer.value.count=res.data.count;
        quer.value.page= Math.ceil(quer.value.count/que.value.size)
    })
}


</script>

<style scoped>

</style>